#ifndef _PLATFORM_H_
#define _PLATFORM_H_

typedef struct elab_device_attr
{
    const char *name;
    bool sole;
    uint8_t type;
} elab_device_attr_t;

typedef struct file_operations file_operations_t;

typedef struct elab_device
{
    elab_device_attr_t attr;
    /* common device interface */
    file_operations_t *ops;
    void *user_data;
    tNode node;
} elab_device_t;

typedef struct file_operations {
int (*write) (elab_device_t *me, const char *buff, size_t lens);
int (*read) (elab_device_t *me, char * buff, size_t lens);
int (*open) (elab_device_t *me);
int (*release) (elab_device_t *me);
int (*select) (elab_device_t *me, unsigned int attr);
}file_operations_t;

elab_device_t* device_find(const char* const name);
void device_register(elab_device_t* ops);
void device_unregister(elab_device_t* ops);

int elab_device_read(elab_device_t *me,
                            char * buff, size_t lens);

int elab_device_write(elab_device_t *me,
                            const char *buff, size_t lens);

int elab_device_open(elab_device_t *me);

int elab_device_release(elab_device_t *me);

int elab_device_select(elab_device_t *me, unsigned int attr);

void elab_system_running(void);

extern bool system_running;

#define SYSTEM_IS_RUNNING() (system_running ? true : false)

#endif
